package com.yqya.springboot.pattern.strategy.biz.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yqya.springboot.pattern.strategy.biz.OrderService;
import com.yqya.springboot.pattern.strategy.biz.handler.AbstractOrderHandler;
import com.yqya.springboot.pattern.strategy.biz.handler.OrderHandlerContext;
import com.yqya.springboot.pattern.strategy.dto.OrderDTO;

/**
 * 订单服务实现类
 *
 * @author Kevin
 * @date 2019-06-29
 */
@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderHandlerContext orderHandlerContext;

    @Override
    public String handle(OrderDTO dto) {
        AbstractOrderHandler orderHandler = orderHandlerContext.getInstance(String.valueOf(dto.getType()));
        String result = orderHandler.handle(dto);
        return result;
    }

}
